/**
 * 模块路径修复
 * @param {string} rawSrcPath 
 */
module.exports = function domainModulePathFix(rawSrcPath) {
  let srcpath = rawSrcPath;
  /* --------------------------------- 导入路径修复开始 --------------------------------- */

  // 移动到src/apphub文件夹
  srcpath = srcpath.replace(
    /src\/(api|stores|utils|models|service|routers|config|metadata|data-sources|bootstrap|node-polyfill|polyfill|AppPresenter|App|Startup|setupGio|growing)/,
    (_, $1) => {
      return `src/apphub/${$1}`;
    }
  );

  // src/modules/voucher-common  ==> src/voucher-common
  srcpath = srcpath.replace(/src\/modules\/voucher-common/, (_, $1) => {
    return `src/voucher-common`;
  });

  // src/components/voucher/   ==>  src/modules/voucher-old/
  srcpath = srcpath.replace(/src\/components\/voucher\//, () => {
    return `src/modules/voucher-old/`;
  });

  // src/components/wechat-wsc => src/modules/components/wechat-wsc
  srcpath = srcpath.replace(
    /src\/components\/(wechat-wsc|wechat|retail|refer\/refer-inventory-lot|expire-tip|common-grid-wsc)\//,
    (_, $1) => {
      return `src/modules/components/${$1}/`;
    }
  );

  // src/components/base-archive/BaseArchiveExport ==> src/components/export/BaseArchiveExport
  srcpath = srcpath.replace(/src\/components\/base-archive\/BaseArchiveExport/, (_, $1) => {
    return `src/components/export/BaseArchiveExport`;
  });
  // src/components/base-archive/BaseArchiveExport ==> src/components/export/BaseArchiveExport
  srcpath = srcpath.replace(/src\/modules\/components\/(category-grid|base-archive)\//, (_, $1) => {
    return `src/components/${$1}/`;
  });
  // "src/apphub/routers/RouterMap" ==> "src/apphub/routers"
  srcpath = srcpath.replace(/src\/apphub\/routers\/RouterMap/, (_, $1) => {
    return `src/apphub/routers`;
  });
  srcpath = srcpath.replace(/src\/modules\/init\/guide\/GuidePagePresenter/, 'src/components/guide/GuidePagePresenter');
  srcpath = srcpath.replace('src/modules/beginning/stock-beginning/BaseList', 'src/components/decouple/BaseList');
  srcpath = srcpath.replace('src/common/handleError', 'src/apphub/common/handleError');

  return srcpath;
};
